﻿using System;
using System.IO;

namespace OpenLS.Spreadsheet.Formats.Biff.Records
{
    internal class SetupRecord : BiffRecord
    {
        private ushort iPaperSize;
        private ushort iScale = 300;
        private ushort iPageStart = 1;
        private ushort iFitWidth = 1;
        private ushort iFitHeight = 1;
        private ushort flags = 4;
        private ushort iRes = 58690;
        private ushort iVRes = 1;
        private double numHdr = 0.3;
        private double numFtr = 0.3;
        private ushort iCopies = 116;

        protected override void ReadContent(BiffReaderContext context, int length)
        {
            iPaperSize = context.ReadUInt16();
            iScale = context.ReadUInt16();
            iPageStart = context.ReadUInt16();
            iFitWidth = context.ReadUInt16();
            iFitHeight = context.ReadUInt16();
            flags= context.ReadUInt16();
            iRes = context.ReadUInt16();
            iVRes = context.ReadUInt16();
            numHdr = context.ReadDouble();
            numFtr = context.ReadDouble();
            iCopies = context.ReadUInt16();

        }

        internal override BiffRecordType RecordType
        {
            get { return BiffRecordType.Setup; }
        }

        internal override void WriteContent(BiffWriterWorkbookContext context)
        {
            context.Write(iPaperSize);
            context.Write(iScale);
            context.Write(iPageStart);
            context.Write(iFitWidth);
            context.Write(iFitHeight);
            context.Write(flags);
            context.Write(iRes);
            context.Write(iVRes);
            context.Write(numHdr);
            context.Write(numFtr);
            context.Write(iCopies );
        }
    }
}